<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>vue</title>
</head>
<body>
<div id="div">
    <div>姓名:{{name}}</div>
    <div>班级:{{classRoom}}</div>
    <button onclick="hi()">打招呼</button>
    <button onclick="update()">修改班级</button>

</div>
<script src="../js/vue.js"></script>
<script>
    let m = new Vue({
        el:"#div",
        data:{
            name:"张三",
            classRoom:"黑马程序员"
        },
        methods:{
            study(){
                alert(this.name+"正在"+this.classRoom+"好好学习");
            },
            update(className){
                this.classRoom=className;
            }
        }
    });
    //定义打招呼方法
    function hi(){
        m.study();
    };
    //定义修改方法
    function update(){
        m.update("船只博客");
    };
</script>
</body>
</html>